<template>
	<view>
		<!-- 没登录的头部 -->
		<view class="hidden-head" v-if="!value">
			<view class="hidden-icon"></view>
			<view class="hidden-text">
				<view class="hidden-text1">Hi~</view>
				<view class="hidden-text2">您还没有登录呢</view>
				<view class="buttons">
					<button type="default">注册</button>
					<navigator url="/pages/user/login/login">
						<button type="default">登陆</button>
					</navigator>

				</view>

			</view>


		</view>
		<!-- 头部 -->
		<view class="user-head" v-else>
			<image :src="userInfo.icon"></image>
			<view class="text-box">
				<view class="user-text1">{{userInfo.nickname}}</view>

				<view class="user-text2">用户名:{{userInfo.username}}</view>
			</view>

		</view>
		<!-- 我的订单 -->
		<view class="order">
			<view class="order-text">我的订单</view>
			<view class="order-line"></view>
			
			<view class="order-item">
 
				<view v-for="(item,index) in order" :key="item.name" class="order-img">
					<!-- <navigator url="`/pages/user/userOrder/userOrder? ${index}`"> -->
					<uni-icons :type="item.icons" size="30" class="user-icon" @tap="touserOrder(index)"></uni-icons>
					<!-- </navigator> -->
					{{item.name}}
				</view>
				
			</view>
			
		</view>
		<!-- 九宫格区域 -->
		<view class="show-box">
			<view class="show-item" v-for="(item,index) in  GongGe" :key="item.name" @tap="iconEvent(index)">
				<uni-icons :type="item.icons" size="30"></uni-icons>
				{{item.name}}
			</view>
		</view>
		<!-- 尾巴 -->
	</view>
</template>

<script>
	import checkLogins from "@/mixins/isLogin.js"
	import {
		getMemberInfo
	} from "@/api/user/index.js"
	export default {
		data() {
			return {
				value: "",
				GongGe: [{
						name: "商品收藏",
						icons: "star"
					},
					{
						name: "品牌",
						icons: "headphones"
					},
					{
						name: "文章收藏",
						icons: "star-filled"
					},
					{
						name: "地址",
						icons: "map-pin"
					},
					{
						name: "卡包",
						icons: "email"
					},
					{
						name: "购物车",
						icons: "cart"
					},
					{
						name: "联系客服",
						icons: "phone"
					},
					{
						name: "",
						icons: ""
					},
					{
						name: "",
						icons: ""
					}
				],
				userInfo: {},
				order: [{
						name: "待付款",
						icons: "email-filled"
					},
					{
						name: "已付款",
						icons: "mail-open"
					},
					{
						name: "已发货",
						icons: "hand-thumbsup"
					},
					{
						name: "已收货",
						icons: "checkmarkempty"
					},
					{
						name: "售后",
						icons: "home"
					}
				]
			};
		},
		mixins: [checkLogins],
		onShow() {
			if (this.checkLogin()) {
				getMemberInfo()
					.then(res => {
						console.log(res)
						this.userInfo = res.data.data.userInfo
					})
				this.value = uni.getStorageSync("token")
			}



		},
		onLoad() {

		},
		methods: {
			touserOrder(index){
				 uni.navigateTo({
				 	url:`/pages/user/userOrder/userOrder?index=${index}`
				 })
				
			},
			iconEvent(index) {
				if (index == 5) {
					uni.navigateTo({
						url: "/pages/home/cart/cart"
					})

				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	body {
		background-color: #007AFF;
	}

	// 隐藏头部
	.hidden-head {
		display: flex;
		align-items: center;

		.hidden-icon {
			margin-left: 20px;
			width: 80px;
			height: 80px;
			border-radius: 50%;
			background-color: #3F536E;
			margin-top: 20px;
		}

		.hidden-text {
			margin-top: 20px;
			margin-left: 20px;
			line-height: 30px;
		}

		.buttons {
			display: flex;

			button:nth-child(2) {
				margin-left: 50px;
			}
		}
	}

	//头部
	.user-head {
		display: flex;

		align-items: center;
		padding: 30px;

		image {
			display: block;
			width: 75px;
			height: 75px;
			border-radius: 50%;
		}

		.text-box {
			margin-left: 20px;
		}
	}

	//我的订单
	.order {
		width: 90%;

		margin: 0 auto;

		.order-text {
			text-indent: 15px;
			padding: 15px;
		}

		.order-line {
			width: 90%;
			height: 1px;
			background-color: #000000;
			margin: 0 auto;

		}

		.order-item {
			display: flex;
			justify-content: space-evenly;
			padding: 15px;

		}

		.order-img {
			display: flex;
			flex-direction: column;
		}
	}

	// 九宫格区域
	.show-box {
		width: 90%;
		margin: 0 auto;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-evenly;
		padding: 20px;

		.show-item {
			width: 100px;
			height: 100px;
			display: flex;
			flex-direction: column;
			text-align: center;

		}
	}
</style>
